package com.raos.pagehelper.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.raos.pagehelper.dao.SysUserDao;
import com.raos.pagehelper.model.SysUser;
import com.raos.pagehelper.utils.PageQuery;

import java.util.List;
import java.util.Map;

/**
 * 用户业务操作实现类
 *
 * @author raos
 * @emil 991207823@qq.com
 * @date 2021/09/04 20:17
 */
public class SysUserServiceImpl implements SysUserServcie {

    private SysUserDao sysUserDao;

    public SysUserServiceImpl(SysUserDao sysUserDao) {
        this.sysUserDao = sysUserDao;
    }

    @Override
    public List<SysUser> queryAll(Map<String, Object> params) {
        return sysUserDao.queryList(params);
    }

    @Override
    public PageInfo<SysUser> queryListByPage(Map<String, Object> params, PageQuery pageQuery) {
        return PageHelper.startPage(pageQuery.getPage(), pageQuery.getLimit())
                .doSelectPageInfo(() -> this.queryAll(params));
    }

    @Override
    public Page<SysUser> queryListByPage2(Map<String, Object> params, PageQuery pageQuery) {
        return PageHelper.startPage(pageQuery.getPage(), pageQuery.getLimit())
                .doSelectPage(() -> this.queryAll(params));
    }

}
